package com.yfqy.app.exception;

import com.yfqy.app.enums.ErrorCode;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.io.Serial;

@Data
@EqualsAndHashCode(callSuper = true)
public class BusinessException extends RuntimeException {

    @Serial
    private static final long serialVersionUID = -7972131521045668011L;

    /**
     * 自定义异常码
     */
    private Integer code;

    /**
     * 已知的异常信息
     */
    private String message;


    private BusinessException() {
    }

    public BusinessException(ErrorCode responseEnum) {
        this.code = responseEnum.getCode();
        this.message = responseEnum.getMessage();
    }

    public BusinessException(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

}